Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle the no-target case through user information. #408

Merged
merged 1 commit into from
Jun 19, 2020

Conversation

olivier-stasse
Copy link
Member

@olivier-stasse olivier-stasse commented Jun 18, 2020

Goal

Handling package with no targets (typically data packages)
Issue #398

Remplacement of PR #403

Principle

The user specifies the property/variable ZERO_TARGET of the target PROJECT_NAME to true:

SET(${PROJECT_NAME}_ZERO_TARGET TRUE)

Then the export of exportTarget.cmake is not generated (currently generating a bug),
and then an expression is set on Config.cmake.in avoiding the inclusion of this file.
This is necessary to avoid later error when upstream packages are using the cmake recipe of this package.

When a normal package is used the expression is true and thus the inclusion of the target is done.

Tested in both situations.

Copy link
Collaborator

@jmirabel jmirabel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with the changes.

I made a proposal for a simpler version (which works only if you don't need variable ZERO_TARGET in downstream packages). If you include it, mind that I didn't run this so I am not sure I escaped correctly all the " and $.

Config.cmake.in Outdated Show resolved Hide resolved
package-config.cmake Outdated Show resolved Hide resolved
@olivier-stasse
Copy link
Member Author

Nice simplification. I just tested it, it worked as proposed.

@jmirabel
Copy link
Collaborator

I let @gergondet merge if it is ok for him now.

@gergondet
Copy link
Member

This looks fine, but:

  1. The variable should be documented in base.cmake
  2. It's a little strange to prefix the variable name with ${PROJECT_NAME} where other such variables use the PROJECT_ prefix (see https://jrl-cmakemodules.readthedocs.io/en/master/pages/base.html#required-variables)
  3. I think PROJECT_EXPORT_NO_TARGET is a better name
  4. @INCLUDE_TARGETS_FILE@ could be replaced with:
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@[email protected]") 
  include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
endif()

@jmirabel
Copy link
Collaborator

4\. `@INCLUDE_TARGETS_FILE@` could be replaced with:
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@[email protected]") 
  include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
endif()

I thought about that too. I preferred the explicit method so that, at configure time, you explicitly say whether or not there is a targets file, rather than looking for it later. This avoids the annoying issue of a file existing but not found. If there is one but you did not find it, it is better to report an error.

@olivier-stasse
Copy link
Member Author

Last commit is correcting point 1, 2 and 3.
I let you decide on point 4.
But my inclination would be in the direction of Joseph.

@@ -154,6 +154,13 @@ if(_PKG_CONFIG_REQUIRES)
endforeach()
list(REMOVE_DUPLICATES _PKG_CONFIG_REQUIRES_LIST)
endif(_PKG_CONFIG_REQUIRES)

if(NOT PROJECT_EXPORT_NO_TARGET)
SET(INCLUDE_TARGETS_FILE "include(\"\${CMAKE_CURRENT_LIST_DIR}/${TARGETS_EXPORT_NAME}.cmake\")")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-set+SET (same below)

@gergondet
Copy link
Member

I agree on point 4 as well. So just two more small changes and it's good too go :)

Lean implementation.
Uses variable PROJECT_EXPORT_NO_TARGET
Documentation for the variable.
From SET to set
@olivier-stasse
Copy link
Member Author

SET -> set done

@jmirabel jmirabel merged commit f4863ab into jrl-umi3218:master Jun 19, 2020
jcarpent pushed a commit to jcarpent/jrl-cmakemodules that referenced this pull request Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants